
#ifndef _NVPAIRS_H_
#define _NVPAIRS_H_

/************************************************************************************************
*
* Name-value pair (one pair)
*
*************************************************************************************************/

class nvPair  {

public:
	nvPair(const String&, const String&);
	~nvPair();

	String getName() { return name; }
	String getValue() { return value; }

protected:
	String name;
	String value;
};





/************************************************************************************************
*
* Name-value pairs - array of name/value pairs
*
*************************************************************************************************/

#define MAX_NVPAIRS 256

class nvPairs {

public:
	nvPairs();	
	nvPairs(const char* );	// This one parses a URL-encoded string
	~nvPairs();

	void addPair(nvPair*);

	uint32 numPairs() const;

	bool8 getPairAt(uint32, String&, String&) const;
	String getValue(const String& ) const;
	char* getURLEncodedString() const;
 
	void setNVDelimiter(char);

	void setFormInput(const char*); 

	//only for a url that has already been decoded from urlDecode and 
	//is NOT safe encoded and does not contain escaped characters
	void setFormInput(const String&); 

	static char* urlEncode(const String&);
	static String urlDecode(const char*);
	static String urlDecode(const String&);

protected:
	nvPair *m_pairs[MAX_NVPAIRS];
	uint32 m_numPairs;
	char m_delimiter;

};

#endif
